<?php
/**
 * add this view, should
 * 1) get event list
 * 2) show event list
 * 3) if click addEvent button, add new event
 * 4) if click on one event, can modify event
 * 
 */
//get active app
$app = Blyn::app()->getActiveApp();
//create event contex
//$eventContext = new BWEvent();
$eventList = array();
//$eventContext->status = 'active';
//$eventList = $app->getEventList($eventContext);
//by default, control is the point to control that render this view
$page = $control;
$addEventAjaxLink = $page->getAjaxLink('Add Event', NULL, NULL, 'weEvent/addEvent');
$deleteEventAjaxLink = $page->getAjaxLink('Delete Event', NULL, NULL, 'weEvent/deleteEvent');
?>
//event list
<link rel="stylesheet" type="text/css"
              href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-datetimepicker.min.css" />
<script  type="text/javascript"
     src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-datetimepicker.min.js"/>

<script type="text/javascript">
  $(function() {
    $('#datetimepicker4').datetimepicker({
      pickTime: false
    });
    $('#datetimepicker3').datetimepicker({
      pickTime: false
    });
    $('#datetimepicker5').datetimepicker({
      pickTime: false
    });
     $("#selectAll").click(function(){ 
      if($(this).attr("checked")=="checked"){ 
        $(":checkbox").attr("checked",true); 
      }else{ 
        $(":checkbox").attr("checked",false); 
      } 
    }); 
  });
</script>
<div id="b_show_operation_flow_content">
    <div id="b_show_operation_content">
<div id="b_show_screenFlow_content">
    <div id="b_show_screen_content">
 

<div><legend>微活动列表</legend></div>
<form action="#" method="post">
    <fieldset>
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>
                        <input type="checkbox" id="selectAll"> 
                    </th>
                    <th>微活动名称</th>
    <!--                <th>数量</th>-->
                    <th>创建人</th>
    <!--                <th>状态</th>-->
                    <th>行动</th>
                </tr> 
            </thead>
        <tbody>
                            <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="1"> 
                        </label></td>
                    <td> 双十一  </td>
                    <td> 张光明  </td>
                    <td>
                        <div class="row-fluid">
                            <a href="#" role="button" data-toggle="modal">修改</a>
                        </div>
                    </td>
                </tr>
                <!-- Modal -->
            
                        <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="checkbox[]" value="2"> 
                        </label></td>
                    <td>双十二 </td>
                    <td>姜方鑫 </td>
                    <td>
                        <div class="row-fluid">
                            <a href="#" role="button" data-toggle="modal">修改</a>
                        </div>
                    </td>
                </tr>
                <!-- Modal -->
            
                </tbody>
    </table>
        
    <div class="row-fluid">
        <a href="#myModal0" role="button" data-toggle="modal" class="btn">添加</a>
                <a class="btn" onclick="jQuery.ajax({'type':'POST','url':'#','beforeSend':function(){$(&quot;#ajax-loaderdiv&quot;).show();},'complete':function(){$(&quot;#ajax-loaderdiv&quot;).hide();},'cache':false,'data':jQuery(this).parents(&quot;form&quot;).serialize(),'success':function(html){jQuery(&quot;#b_show_screenFlow_content&quot;).html(html)}});return false;" href="#">删除</a>            </div>
    <div id="myModal0" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        


<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3>微活动添加</h3>
</div>
<div class="modal-body">

    <div class="tabbable tabs-right" style="margin-top: 15px;"> <!-- Only required for left/right tabs -->
        <ul class="nav nav-tabs" style="margin-bottom: 15px">
            <li class="active"><a href="#tab10" data-toggle="tab">基本信息</a></li>
            <li><a href="#tab20" data-toggle="tab">活动设置</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="tab10" style="min-height: 270px">
                <div class="well">
                    <label>活动名称:</label>
                    <input value="" name="name0" placeholder="Type name..." required="required" id="name0" type="text">                
                    <label>活动描述:</label>                
                    <textarea name="description0" placeholder="Type description..." id="description0"></textarea>                </div>
            </div>
            <div class="tab-pane" id="tab20" style="min-height: 270px">
                <div class="well">
                    <label>活动开始时间:</label>                    
               <div class="input-append" id="datetimepicker4">
    <input data-format="yyyy-MM-dd" type="text">
    <span class="add-on">
      <i data-date-icon="icon-calendar" data-time-icon="icon-time" class="icon-calendar">
      </i>
    </span>
  </div>
                     <label>活动结束时间:</label>                    
             <div class="input-append" id="datetimepicker3">
    <input data-format="yyyy-MM-dd" type="text">
    <span class="add-on">
      <i data-date-icon="icon-calendar" data-time-icon="icon-time" class="icon-calendar">
      </i>
    </span>
  </div>            <label>微活动发起人:</label>
                    <input value="张三" name="amount0" placeholder="Type amount..." required="required" id="amount0" type="text"/>   
                    <label>微活动发送消息:</label>                
                    <textarea name="description0" placeholder="Event message..." id="description0"></textarea> 
                     <label>微活动发送消息时间:</label>                    
             <div class="input-append" id="datetimepicker5">
    <input data-format="yyyy-MM-dd" type="text">
    <span class="add-on">
      <i data-date-icon="icon-calendar" data-time-icon="icon-time" class="icon-calendar">
      </i>
    </span>
  </div> 
                </div>
                
            </div>
        </div>
    </div>

</div>     
<div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <a class="btn btn-primary" onclick="jQuery.ajax({'complete':function(){$(&quot;#ajax-loaderdiv&quot;).hide();$(&quot;#myModal0&quot;).modal(&quot;hide&quot;);$(&quot;#refreshIt&quot;).click();},'type':'POST','url':'/billyn-dev/index.php/site/index/bn/612_616_696/b_ajaxLinkId/link0','beforeSend':function(){$(&quot;#ajax-loaderdiv&quot;).show();},'cache':false,'data':jQuery(this).parents(&quot;form&quot;).serialize(),'success':function(html){jQuery(&quot;#myModal0&quot;).html(html)}});return false;" href="#">保存</a></div>



    </div>   
    <div><input type="hidden" name="curPageNo" value="1"></div>
    <a id="refreshIt" style="display:none" onclick="jQuery.ajax({'type':'POST','url':'#','beforeSend':function(){$(&quot;#ajax-loaderdiv&quot;).show();},'complete':function(){$(&quot;#ajax-loaderdiv&quot;).hide();},'cache':false,'data':jQuery(this).parents(&quot;form&quot;).serialize(),'success':function(html){jQuery(&quot;#b_show_screenFlow_content&quot;).html(html)}});return false;" href="#">Refresh</a></fieldset>
  
<div class="pagination">  
  <ul>  
    <li class="active">
            <a href="javascript:void()">前一页</a>    </li>  
        <li class="active">
        <a href="javascript:void()">1</a>    </li>  
        <li class="active">
            <a href="javascript:void()">后一页</a>    </li>  
  </ul>  
</div>  
</form>
  
</div>      
</div>      
</div>      
</div>
<!--
<script>
function allSelect()//全选
{  
　　var ids=$("input[name='id']");  
　　for(var i=0;i<ids.length;i++)
　　{   
　　　　ids[i].checked="checked";  
　　}
}
function noSelAll()//反选
{ 
　　var ids=$("input[name='id']");
　　 for(var i=0;i<ids.length;i++)
　　{ 
      ids[i].checked="";
 　　　　/*
        if(ids[i].checked==true)
　　　　{    
　　　　　　ids[i].checked="";   
　　　　}else{   
 　　　　　　ids[i].checked="checked";  
 　　　}  */
　　}
}

function CheckaddEvent()
{ 
    var ids=$("input[name='id']");
    for(var i=0;i<ids.length;i++)
    { 
        if(ids[i].checked){ 
        return; 
        } 
    } 
    window.alert('请勾选需要修改的活动！'); 
} 
function CheckdelEvent()
{ 
    var ids=$("input[name='id']");
    for(var i=0;i<ids.length;i++)
    { 
        if(ids[i].checked){ 
        return; 
        } 
    } 
    window.alert('请勾选需要删除的活动！'); 
} 
</script>
<table class="table table-striped table-bordered table-condensed" style="margin-bottom: 2px;">
	        <tr >
                        <td >
                          <a class="btn" href="#">活动添加</a>
                          <a class="btn" href="javascript:CheckaddEvent()">活动修改</a>
                          <a class="btn" href="javascript:CheckdelEvent()">活动删除</a>
                      </td>

                    </tr>
      </table>
<table class="table table-striped table-bordered table-condensed">
	        <thead>
          <tr>
            <th style="width: 30px; text-align: center;">序号</th>
            <th style="width: 30px; text-align: center;">选择</th>
            <th style=" text-align:left">活动标题</th>
  
          </tr>
        </thead>
        <tbody>
          <tr>
            <td style="width: 30px; text-align: center;">1</td>
             <td style="width: 30px; text-align: center;"><input name="id" type="checkbox" id="id" value="1"></td>
            <td style="text-align:left">双十一</td>
          </tr>
          <tr>
            <td style="width: 30px; text-align: center;">2</td>
            <td style="width: 30px; text-align: center;"><input name="id" type="checkbox" id="id" value="2"></td>
            <td style="text-align:left">双十二促销</td>
          </tr>
          <tr>
            <td style="width: 30px; text-align: center;">3</td>
            <td style="width: 30px; text-align: center;"><input name="id" type="checkbox" id="id" value="3"></td>
            <td style="text-align:left">神探伽俐略</td>
          </tr>
          <tr bgcolor="#ffffff">
              <td style="height: 10px;" colspan="10">
	&nbsp;
	<a href="javascript:allSelect()" class="coolbg">全选</a>
	<a href="javascript:noSelAll()" class="coolbg">取消</a>
	<a href="javascript:update(0)" class="coolbg">&nbsp;更新&nbsp;</a>

        <a href="#" >首 页</a> <a href="#" >1</a> <a  href="#">2</a> <a href="#">3</a> 
        <a href="#" >末 页</a>
        <a href="#">下一页</a> 
              </td>
        </tr>
        </tbody>
      </table>
-->
<?php foreach ($eventList as $id => $event) { ?>

<?php } ?>
<p>
    <?php
    echo $addEventAjaxLink;
    ?>
</p>
<p>
    <?php
    echo $deleteEventAjaxLink;
    ?>
</p>
<h4>List Event</h4>
